package cn.softcits.thread;

/**
 * @author Rocket
 * @version 10.0.1
 * @date 2021-07-04 9:30 AM
 */
public class Thread01 extends Thread {

    private String name;

    public Thread01(String name) {
        this.name = name;
    }


    @Override
    public void run() {
        setName(name);
//        if(name.equals("zhangsan")) {
//            try {
//                Thread.sleep(300);
//            } catch (InterruptedException e) {
//                e.printStackTrace();
//            }
//        }

        if(name.equals("lisi")) {
            this.setPriority(Thread.MAX_PRIORITY);
        } else {
            this.setPriority(Thread.MIN_PRIORITY);
        }
        for(int i = 0; i < 100; i++)
            System.out.println(this.getName() + "  is working");

    }

    public static void main(String[] args) {
        Thread01 th = new Thread01("zhangsan");
        th.start();
        Thread01 th2 = new Thread01("lisi");
        th2.start();
        Thread.currentThread().setPriority(Thread.MIN_PRIORITY);

        System.out.println("Main Thread is working");

    }


}
